package com.example.demo.controller;

import com.example.demo.entity.Shift;

import com.example.demo.pojo.Staff;
import com.example.demo.service.Impl.ShiftServiceImpl;
import com.example.demo.service.StaffService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Project:demo
 * @Description:
 * @Author: Mr.Hunter
 * @Date:2023/5/25/17:16
 */
@RestController
@RequestMapping("/Staff")
public class StaffController {
    @Autowired
    private StaffService staffService;


    @ApiOperation("通过店铺ip查询员工")
    @ResponseBody
    @GetMapping(value = "/selectStaffAllByStore/{store_id}")
    public List<Staff> selectStaffAllByStore(@PathVariable("store_id")Integer storeId){
        return staffService.selectStaffAllByStore(storeId);
    }

    @ApiOperation("通过员工ID查找员工")
    @ResponseBody
    @GetMapping("/selectAllStaffById/{ID}")
    public List<Staff> selectAllStaffById(@PathVariable("ID") Integer staffId){
        return staffService.selectAllStaffById(staffId);
    }

    @ApiOperation("通过员工姓名查找员工")
    @ResponseBody
    @GetMapping("/selectAllStaffByName/{name}")
    public List<Staff> selectAllStaffByName(@PathVariable("name") String staffName){
        return staffService.selectAllStaffByName(staffName);
    }

    @ApiOperation("增加员工信息")
    @ResponseBody
    @PostMapping("/insertStaff/{name}/{mail}/{pos}/{shopID}")
    public Staff insertStaff(@PathVariable String name, @PathVariable String mail, @PathVariable String pos,@PathVariable Integer shopID) {
        staffService.insertStaff(name, mail, pos,shopID);
        return null;

    }

    @ApiOperation("根据员工ID更新员工信息")
    @ResponseBody
    @PostMapping("/updateStaffById/{staffId}/{name}/{mail}/{pos}/{shopID}")
    public Staff updateStaffById(@PathVariable Integer staffId,@PathVariable String name, @PathVariable String mail, @PathVariable String pos,@PathVariable Integer shopID) {
        staffService.updateStaffById(staffId,name, mail, pos,shopID);
        return null;

    }

    @ApiOperation("根据员工姓名更新员工信息")
    @ResponseBody
    @PostMapping("/updateStaffByName/{name}/{mail}/{pos}/{shopID}")
    public Staff updateStaffByName(@PathVariable String name, @PathVariable String mail, @PathVariable String pos,@PathVariable Integer shopID) {
        staffService.updateStaffByName(name, mail, pos,shopID);
        return null;

    }

    @ApiOperation("根据员工ID删除员工信息")
    @ResponseBody
    @DeleteMapping("/deleteStaffById/{staffId}")
    public void deleteStaffById(@PathVariable Integer staffId) {
        staffService.deleteStaffById(staffId);
    }

    @ApiOperation("根据员工姓名删除员工信息")
    @ResponseBody
    @DeleteMapping("/deleteStaffByName/{name}")
    public void deleteStaffByName(@PathVariable String name) {
        staffService.deleteStaffByName(name);
    }

}